package com.zhang.cn.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@EnableAutoConfiguration
@RestController
@ControllerAdvice
public class indexController {
	@RequestMapping("/get")
	public String get() {
		return "success";
	}

	@RequestMapping()
	public String indexController() {
		// int i=1/0;
		return "indexController";
	}

	@ExceptionHandler(RuntimeException.class)
	@ResponseBody
	public Map<String, Object> exceptionMap() {
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put("errorException", "404");
		resultMap.put("errormsg", "系统错误");
		return resultMap;
	}

	@Value("${name}")
	private String name;

	@ResponseBody
	@RequestMapping("/getprop")
	public String getprop() {
		return name;
	}

	public static void main(String[] args) {
		SpringApplication.run(indexController.class, args);
	}

	@Value("${name}")
	private String nameString;

	@RequestMapping("/testnameString")
	public String testnameString() {

		return nameString;
	}
}
